/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = 'regional';
  
  checkConfig(config);
  @endpoint = getEndpoint('nlp-automl', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model CreateAsyncPredictRequest {
  content?: string(name='Content'),
  detailTag?: string(name='DetailTag', example='false'),
  fetchContent?: string(name='FetchContent', example='true,false'),
  fileContent?: string(name='FileContent', example='[base64 encode content]'),
  fileType?: string(name='FileType', example='text,html,pdf,docx,doc'),
  fileUrl?: string(name='FileUrl', example='http://127.0.0.1/example.docx'),
  modelId?: int32(name='ModelId', example='1'),
  modelVersion?: string(name='ModelVersion', example='V1'),
  serviceName?: string(name='ServiceName', example='ContractNERPretrain'),
  serviceVersion?: string(name='ServiceVersion', example='V1'),
  topK?: int32(name='TopK', example='0,3'),
}

model CreateAsyncPredictResponseBody = {
  asyncPredictId?: long(name='AsyncPredictId', example='1'),
  requestId?: string(name='RequestId', example='E5C4531B-8331-5CD5-BEB3-2F8B58A4D680'),
}

model CreateAsyncPredictResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: CreateAsyncPredictResponseBody(name='body'),
}

async function createAsyncPredictWithOptions(request: CreateAsyncPredictRequest, runtime: Util.RuntimeOptions): CreateAsyncPredictResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.content)) {
    body['Content'] = request.content;
  }
  if (!Util.isUnset(request.detailTag)) {
    body['DetailTag'] = request.detailTag;
  }
  if (!Util.isUnset(request.fetchContent)) {
    body['FetchContent'] = request.fetchContent;
  }
  if (!Util.isUnset(request.fileContent)) {
    body['FileContent'] = request.fileContent;
  }
  if (!Util.isUnset(request.fileType)) {
    body['FileType'] = request.fileType;
  }
  if (!Util.isUnset(request.fileUrl)) {
    body['FileUrl'] = request.fileUrl;
  }
  if (!Util.isUnset(request.modelId)) {
    body['ModelId'] = request.modelId;
  }
  if (!Util.isUnset(request.modelVersion)) {
    body['ModelVersion'] = request.modelVersion;
  }
  if (!Util.isUnset(request.serviceName)) {
    body['ServiceName'] = request.serviceName;
  }
  if (!Util.isUnset(request.serviceVersion)) {
    body['ServiceVersion'] = request.serviceVersion;
  }
  if (!Util.isUnset(request.topK)) {
    body['TopK'] = request.topK;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'CreateAsyncPredict',
    version = '2019-11-11',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function createAsyncPredict(request: CreateAsyncPredictRequest): CreateAsyncPredictResponse {
  var runtime = new Util.RuntimeOptions{};
  return createAsyncPredictWithOptions(request, runtime);
}

model FindUserReport4AlinlpRequest {
  beginTime?: string(name='BeginTime'),
  customerUserParentId?: long(name='CustomerUserParentId'),
  endTime?: string(name='EndTime'),
  modelType?: string(name='ModelType'),
  type?: string(name='Type'),
}

model FindUserReport4AlinlpResponseBody = {
  code?: string(name='Code'),
  data?: [ 
    {
      failCount?: long(name='FailCount'),
      qpsMax?: int32(name='QpsMax'),
      rptTime?: string(name='RptTime'),
      successCount?: long(name='SuccessCount'),
      totalCount?: long(name='TotalCount'),
    }
  ](name='Data'),
  requestId?: string(name='RequestId'),
}

model FindUserReport4AlinlpResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: FindUserReport4AlinlpResponseBody(name='body'),
}

async function findUserReport4AlinlpWithOptions(request: FindUserReport4AlinlpRequest, runtime: Util.RuntimeOptions): FindUserReport4AlinlpResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.beginTime)) {
    body['BeginTime'] = request.beginTime;
  }
  if (!Util.isUnset(request.customerUserParentId)) {
    body['CustomerUserParentId'] = request.customerUserParentId;
  }
  if (!Util.isUnset(request.endTime)) {
    body['EndTime'] = request.endTime;
  }
  if (!Util.isUnset(request.modelType)) {
    body['ModelType'] = request.modelType;
  }
  if (!Util.isUnset(request.type)) {
    body['Type'] = request.type;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'FindUserReport4Alinlp',
    version = '2019-11-11',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function findUserReport4Alinlp(request: FindUserReport4AlinlpRequest): FindUserReport4AlinlpResponse {
  var runtime = new Util.RuntimeOptions{};
  return findUserReport4AlinlpWithOptions(request, runtime);
}

model GetAsyncPredictRequest {
  asyncPredictId?: int32(name='AsyncPredictId', example='1629'),
}

model GetAsyncPredictResponseBody = {
  asyncPredictId?: int32(name='AsyncPredictId', example='1629'),
  content?: string(name='Content', example='json string'),
  requestId?: string(name='RequestId', example='EBF1AAD7-A3FB-4A78-B5E9-8356324B12B2'),
  status?: int32(name='Status', example='2'),
}

model GetAsyncPredictResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: GetAsyncPredictResponseBody(name='body'),
}

async function getAsyncPredictWithOptions(request: GetAsyncPredictRequest, runtime: Util.RuntimeOptions): GetAsyncPredictResponse {
  Util.validateModel(request);
  var query = OpenApiUtil.query(Util.toMap(request));
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetAsyncPredict',
    version = '2019-11-11',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'GET',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function getAsyncPredict(request: GetAsyncPredictRequest): GetAsyncPredictResponse {
  var runtime = new Util.RuntimeOptions{};
  return getAsyncPredictWithOptions(request, runtime);
}

model GetPredictResultRequest {
  content?: string(name='Content'),
  detailTag?: string(name='DetailTag', example='true'),
  modelId?: int32(name='ModelId', example='1818'),
  modelVersion?: string(name='ModelVersion', example='V1'),
  topK?: int32(name='TopK', example='3'),
}

model GetPredictResultResponseBody = {
  content?: string(name='Content'),
  requestId?: string(name='RequestId', example='32CE4E89-218B-4DAE-A103-E6BFA66EE63B'),
}

model GetPredictResultResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: GetPredictResultResponseBody(name='body'),
}

async function getPredictResultWithOptions(request: GetPredictResultRequest, runtime: Util.RuntimeOptions): GetPredictResultResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.content)) {
    body['Content'] = request.content;
  }
  if (!Util.isUnset(request.detailTag)) {
    body['DetailTag'] = request.detailTag;
  }
  if (!Util.isUnset(request.modelId)) {
    body['ModelId'] = request.modelId;
  }
  if (!Util.isUnset(request.modelVersion)) {
    body['ModelVersion'] = request.modelVersion;
  }
  if (!Util.isUnset(request.topK)) {
    body['TopK'] = request.topK;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'GetPredictResult',
    version = '2019-11-11',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function getPredictResult(request: GetPredictResultRequest): GetPredictResultResponse {
  var runtime = new Util.RuntimeOptions{};
  return getPredictResultWithOptions(request, runtime);
}

model RunPreTrainServiceRequest {
  predictContent?: string(name='PredictContent'),
  serviceName?: string(name='ServiceName', example='ReviewAnalysis'),
  serviceVersion?: string(name='ServiceVersion', example='V1'),
}

model RunPreTrainServiceResponseBody = {
  billingCount?: int32(name='BillingCount'),
  predictResult?: string(name='PredictResult'),
  requestId?: string(name='RequestId', example='7310FFCF-9FE8-4257-AE38-0E1AD828C2CC'),
}

model RunPreTrainServiceResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: RunPreTrainServiceResponseBody(name='body'),
}

async function runPreTrainServiceWithOptions(request: RunPreTrainServiceRequest, runtime: Util.RuntimeOptions): RunPreTrainServiceResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.predictContent)) {
    body['PredictContent'] = request.predictContent;
  }
  if (!Util.isUnset(request.serviceName)) {
    body['ServiceName'] = request.serviceName;
  }
  if (!Util.isUnset(request.serviceVersion)) {
    body['ServiceVersion'] = request.serviceVersion;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'RunPreTrainService',
    version = '2019-11-11',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function runPreTrainService(request: RunPreTrainServiceRequest): RunPreTrainServiceResponse {
  var runtime = new Util.RuntimeOptions{};
  return runPreTrainServiceWithOptions(request, runtime);
}

model RunPreTrainServiceNewRequest {
  predictContent?: string(name='PredictContent'),
  serviceName?: string(name='ServiceName'),
  serviceVersion?: string(name='ServiceVersion'),
}

model RunPreTrainServiceNewResponseBody = {
  billingCount?: int32(name='BillingCount'),
  predictResult?: string(name='PredictResult'),
  requestId?: string(name='RequestId'),
}

model RunPreTrainServiceNewResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: RunPreTrainServiceNewResponseBody(name='body'),
}

async function runPreTrainServiceNewWithOptions(request: RunPreTrainServiceNewRequest, runtime: Util.RuntimeOptions): RunPreTrainServiceNewResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.predictContent)) {
    body['PredictContent'] = request.predictContent;
  }
  if (!Util.isUnset(request.serviceName)) {
    body['ServiceName'] = request.serviceName;
  }
  if (!Util.isUnset(request.serviceVersion)) {
    body['ServiceVersion'] = request.serviceVersion;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'RunPreTrainServiceNew',
    version = '2019-11-11',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function runPreTrainServiceNew(request: RunPreTrainServiceNewRequest): RunPreTrainServiceNewResponse {
  var runtime = new Util.RuntimeOptions{};
  return runPreTrainServiceNewWithOptions(request, runtime);
}

